# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Xeonacid <h.dwwwwww at gmail dot com>

_pyname=cle
pkgname=python-${_pyname}
pkgver=9.2.69
_testbinaries_ver=9.2.69
pkgrel=1
pkgdesc='Loads binaries and their libraries, resolves imports and provides an abstraction of process memory'
url='https://github.com/angr/cle'
arch=('any')
license=('custom:BSD')
depends=('python' 'python-pyelftools' 'python-cffi' 'python-pyvex' 'python-pefile' 'python-sortedcontainers')
optdepends=(
  'python-claripy: symbolic constraints'
  'python-minidump: minidump'
  'python-pyxbe: xbe'
  'python-arpy: ar'
  'python-pyaxmlparser: apk'
)
makedepends=('python-build' 'python-installer' 'python-wheel' 'python-setuptools')
checkdepends=('python-pytest' 'python-minidump' 'python-pyxbe' 'python-arpy' 'python-claripy' 'python-pyaxmlparser')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz"
        "https://github.com/angr/binaries/archive/v${_testbinaries_ver}/angr-binaries-${_testbinaries_ver}.tar.gz")
sha512sums=('c13d144fbc42373cb477858b4079fc96d5614ad8bd442f21bbdba4d60f013eaf548ea0221384b7504ab215afe5cad6b1571ddf18e9eef893fa383351966fcebf'
            '31dbf15b07ac5bf35d5043f1141a0f56e496c6aba983d78853e96666509f9732257405f472bcd4864e3f7b2b196c23691c9ac4182a7a703d6e7f1f5efb05d187')
b2sums=('bf6dfb47eee9c79a28cd3f13a90b4f5f29efdc61aebf4e5c4ba02435f44ed437e45832f6cff29b2fcb7f34cf04b0c3935387cd7836a51de73c07659d7acbef53'
        '82dc89e2b6f0761b30ad421909aab3858d25be8f9a37b5ec1be6ef7615afcbff7ded4a8d31825e35cd5ca443920c63c570766b5ad5ac9f66b1c22239fd08ced6')

prepare() {
  ln -s binaries-${_testbinaries_ver} binaries
}

build() {
  cd ${_pyname}-${pkgver}
  python -m build --wheel --no-isolation
}

check() {
  cd ${_pyname}-${pkgver}
  PYTHONPATH=build/lib pytest
}

package() {
  cd ${_pyname}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
